package com.hisoft.entity;

import java.util.List;

import org.apache.log4j.Logger;

import com.hisoft.type.ResultEnum;

public class Loop extends ABaseTag {
	Logger logger = Logger.getLogger(Loop.class);
	//循环的次数
	private String time;
	//操作对象的集合
	private List<ABaseTag> loop;
	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public List<ABaseTag> getLoop() {
		return loop;
	}

	public void setLoop(List<ABaseTag> loop) {
		this.loop = loop;
	}

	public Loop() {
		append(this.getClass().getName());
	}

	@Override
	public String toString() {
		String str = "Loop ";
		for (Object o : loop) {
			str += o.toString() + "\n";
		}
		return str;
	}

	@Override
	public String excute() {
		beforeExcute();
		logger.info(toString());
		boolean flag = true;
		for (ABaseTag temp : loop) {
			flag = flag & (temp.excute().contains("" + ResultEnum.PASS));
		}
		if (flag == true) {
			setResult(ResultEnum.PASS);
			return "" + ResultEnum.PASS;
		} else {
			return "" + flag;
		}
	}

}
